package demo3;
/*
求出数组当中的最大值和最小值
 */
public class ArrayTest8 {
    public static void main(String[] args) {
        int[] array = {1, 3, 52, 2, 3, 1, 43, 43, 312, 23, 234, 23, 4, 324, 32, 41, 4, 12, 312, 3, 12, 412, 4, 124, 12};
        int max = array[0];//比武擂台
        int min = array[0];

        for (int i = 1; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }

        for (int i = 1; i < array.length; i++) {
            if (array[i] < min) {
                min = array[i];
            }
        }
        System.out.println("最大值是："+max+"。最小值是:"+min);

    }
}
